import '../model/school_grade_model.dart';
import '../utils/request.dart';

///学校年级API
class SchoolGradeApi {
  SchoolGradeApi._();

  static final _signleton = SchoolGradeApi._();

  factory SchoolGradeApi() => _signleton;

  ///获取学校年级列表
  Future<List<SchoolGradeRes>> grades(final SchoolGradeReq req) => request
          .getHandler(
              path: '/school/${req.schoolId}/grades', params: req.toMap())
          .then(
        (res) {
          final items = res.toList;
          if (items.isNotEmpty) {
            return items.map((item) => SchoolGradeRes.fromMap(item)).toList();
          }
          return [];
        },
      );
}

///学校年级-单例
final schoolGradeApi = SchoolGradeApi();
